package com.softa.vo;

import com.github.pagehelper.PageInfo;

import java.util.Collection;
import java.util.List;

/**
 *  列表定制
 * @author yangl
 *
 */
public class DataGridResponse {
	private long total;
	private Iterable<?> rows;

	public long iTotalRecords;
	public long iTotalDisplayRecords;
	private Iterable<?> aaData;
	public int sEcho;

	public DataGridResponse(PageInfo<?> pageInfo, int sEcho) {
		this.aaData = pageInfo.getList();
		this.iTotalDisplayRecords = pageInfo.getTotal();
		this.iTotalRecords = pageInfo.getTotal();
		this.sEcho = sEcho;
		this.total = pageInfo.getTotal();
	}

	public DataGridResponse(Collection<?> rows, int sEcho) {
		this.aaData = rows;
		this.iTotalDisplayRecords = rows.size();
		this.iTotalRecords = rows.size();
		this.sEcho = sEcho;
		this.total = rows.size();
	}

	public DataGridResponse(long total, Iterable<?> rows) {
		super();
		this.total = total;
		this.rows = rows;
	}

	public DataGridResponse(PageInfo<?> pageInfo) {
		this.setRows(pageInfo.getList());
		this.setTotal(pageInfo.getTotal());
	}

	public DataGridResponse(List<?> list) {
		if (list != null) {
			this.total = list.size();
			this.rows = list;
		}

	}

	public long getTotal() {
		return total;
	}

	public void setTotal(long total) {
		this.total = total;
	}

	public Iterable<?> getRows() {
		return rows;
	}

	public void setRows(Iterable<?> rows) {
		this.rows = rows;
	}

	public long getiTotalRecords() {
		return iTotalRecords;
	}

	public void setiTotalRecords(long iTotalRecords) {
		this.iTotalRecords = iTotalRecords;
	}

	public long getiTotalDisplayRecords() {
		return iTotalDisplayRecords;
	}

	public void setiTotalDisplayRecords(long iTotalDisplayRecords) {
		this.iTotalDisplayRecords = iTotalDisplayRecords;
	}

	public Iterable<?> getAaData() {
		return aaData;
	}

	public void setAaData(Iterable<?> aaData) {
		this.aaData = aaData;
	}

	public int getsEcho() {
		return sEcho;
	}

	public void setsEcho(int sEcho) {
		this.sEcho = sEcho;
	}
}
